package com.teamcenter.rac.massupdate.providers;

import org.apache.log4j.Logger;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.views.properties.IPropertySource;

import com.teamcenter.rac.kernel.TCComponent;
import com.teamcenter.rac.kernel.TCSession;
import com.teamcenter.rac.massupdate.Activator;
import com.teamcenter.rac.massupdate.model.UpdateResult;
import com.teamcenter.rac.massupdate.utils.SourceHelper;
import com.teamcenter.rac.providers.delegates.DefaultLabelProviderDelegate;

public class UpdateResultLabelProvider extends DefaultLabelProviderDelegate {
	private TCSession m_tcSession;

	public UpdateResultLabelProvider(String paramString) {
		setProperty(paramString);
	}

	public String getText(Object paramObject) {
		if ((paramObject != null) && ((paramObject instanceof UpdateResult))) {
			UpdateResult localUpdateResult = (UpdateResult) paramObject;
			String str = getProperty();
			if (str.equals("resultStatus")) {
				int i = localUpdateResult.getResultStatus();
				return UpdateResult.UpdateResultStatus.fromIntToString(i);
			}
			if (str.equals("resultComment")) {
				return localUpdateResult.getResultComment();
			}
			if (str.equals("impactedPart")) {
				return (String) localUpdateResult.getPropertyValue("object_string");
			}
		}
		return super.getText(paramObject);
	}

	public Image getImage(Object paramObject) {
		if ((paramObject != null) && ((paramObject instanceof UpdateResult))) {
			String str = getProperty();
			if (str.equals("impactedPart")) {
				UpdateResult localUpdateResult = (UpdateResult) paramObject;
				IPropertySource localIPropertySource = localUpdateResult.getImpactedPart();
				if (localIPropertySource != null) {
					TCComponent localTCComponent = SourceHelper.getAssociatedComponent(localIPropertySource,
							getTCSession());
					if (localTCComponent != null) {
						return getComponentImage(localTCComponent);
					}
				}
			}
		}
		return null;
	}

	protected TCSession getTCSession() {
		try {
			if (this.m_tcSession == null) {
				this.m_tcSession = ((TCSession) Activator.getDefault().getSessionService()
						.getSession(TCSession.class.getName()));
			}
		} catch (Exception localException) {
			Logger.getLogger(UpdateResultLabelProvider.class).error(localException.getLocalizedMessage(),
					localException);
		}
		return this.m_tcSession;
	}
}

/*
 * Location: D:\下载\Fw_
 * 金卡反编译需求\com.teamcenter.rac.massupdate_11000.2.0.jar!\com\teamcenter\rac\
 * massupdate\providers\UpdateResultLabelProvider.class Java compiler version: 7
 * (51.0) JD-Core Version: 0.7.1
 */